//
//  TouzhujiluCell.m
//  SSC
//
//  Created by 红沙尘 on 17/6/10.
//  Copyright © 2017年 红沙尘. All rights reserved.
//

#import "TouzhujiluCell.h"

@implementation TouzhujiluCell
{
    __weak IBOutlet NSLayoutConstraint *lineD;
    __weak IBOutlet NSLayoutConstraint *lineC;
    __weak IBOutlet NSLayoutConstraint *lineB;
    __weak IBOutlet NSLayoutConstraint *lineA;
    __weak IBOutlet UIView *bgView;
    
    __weak IBOutlet UILabel *qiLabel;
    __weak IBOutlet UILabel *wanfaLabel;
    __weak IBOutlet UILabel *haomaLabel;
    __weak IBOutlet UILabel *beishuLabel;
    __weak IBOutlet UILabel *zhushuLabel;
    __weak IBOutlet UILabel *moneyLabel;
    __weak IBOutlet UILabel *caizhongLabel;
    
    __weak IBOutlet UILabel *zhongjiangLabel;
}
- (void)awakeFromNib {
    [super awakeFromNib];
    
    bgView.layer.borderWidth = LineHeight;
    bgView.layer.borderColor = COLOR_CCCCCC.CGColor;
    
    lineA.constant = LineHeight;
    lineB.constant = LineHeight;
    lineC.constant = LineHeight;
    lineD.constant = LineHeight;
}

- (void)loadWithDict:(NSMutableDictionary *)dict {
    
    haomaLabel.text  = [NSString stringWithFormat:@"号码: %@",[self haomaWithDict:dict]];
    moneyLabel.text  = [NSString stringWithFormat:@"金额: %@",dict[@"amount"]];
    qiLabel.text     = [NSString stringWithFormat:@"期次: %@",[NSString safeString:dict[@"issue"]]];
    zhushuLabel.text = [NSString stringWithFormat:@"注数: %@",[NSString safeString:dict[@"numbers"]]];
    caizhongLabel.text = [MTool caizhongWithType:[dict[@"otype"] intValue]];
    [self winstatusWithDict:dict];
}

- (NSString *)haomaWithDict:(NSDictionary *)dict {
    
    NSArray *list = dict[@"list"];
    
    NSString *code = @"5# | 4# | 3# | 2# | 1#";
    
    for (int i = 0; i <list.count; i ++) {
        NSDictionary *listDict = list[i];
        
        NSString *playname = listDict[@"playname"];
        
        playname = [playname stringByReplacingOccurrencesOfString:@"▼" withString:@""];
        
        if ([playname isEqualToString:@"一星定位胆"]) {
            
            NSString *place = [NSString safeString:listDict[@"place"]];
            
            code = [code stringByReplacingOccurrencesOfString:[NSString stringWithFormat:@"%@#",place]
                                                   withString:listDict[@"code"]];
            
        } else if ([playname isEqualToString:@"龙虎和>万个"]) {
            code = [MTool longhuheCode:listDict[@"code"]];
        } else {
            code = listDict[@"code"];
        }
        
        beishuLabel.text = [NSString stringWithFormat:@"倍数: %@",listDict[@"doubles"]];
        wanfaLabel.text = [NSString stringWithFormat:@"玩法: %@",playname];
    }
    
    code = [code stringByReplacingOccurrencesOfString:@"5#" withString:@"-"];
    code = [code stringByReplacingOccurrencesOfString:@"4#" withString:@"-"];
    code = [code stringByReplacingOccurrencesOfString:@"3#" withString:@"-"];
    code = [code stringByReplacingOccurrencesOfString:@"2#" withString:@"-"];
    code = [code stringByReplacingOccurrencesOfString:@"1#" withString:@"-"];
    
    return code;
}

- (void)winstatusWithDict:(NSDictionary *)dict {
    
    //0未中奖，1中奖，2未开奖
    NSString *winstatus = [NSString safeString:dict[@"winstatus"]];
    
    NSDictionary *winDict = @{@"0":@"未中奖",
                              @"1":@"中奖",
                              @"2":@"未开奖"};
    zhongjiangLabel.text = winDict[winstatus];
    
    if ([zhongjiangLabel.text isEqualToString:@"中奖"]) {
        zhongjiangLabel.textColor = COLOR_FF5253;
    } else {
        zhongjiangLabel.textColor = Color666666;
    }
}



@end
